package com.otherTest.enums;

/**
 * Created by Administrator on 2017/6/22 0022.
 */
public enum TestEnum {

    doc(1), png(2), jpg(3), ppt(4);


    //通过括号赋值,而且必须带有一个参构造器和一个属性跟方法，否则编译出错
    private int value;

    TestEnum(int value) {
        this.value = value;
    }

    public static int getValueByKey() {
        for (TestEnum t : TestEnum.values()) {
            System.out.println(t);
        }

        for (TestEnum t : TestEnum.values()) {
            System.out.println(t.getValue());
        }
        return 0;
    }

    public static void main(String[] args) {
        TestEnum.getValueByKey();
    }

    public int getValue() {
        return value;
    }
}
